package com.whmskj.xjlhsc.stationmachine.service.imp;

import com.whmskj.xjlhsc.stationmachine.mapper.RealTimeMachineInspectionMapper;
import com.whmskj.xjlhsc.stationmachine.pojo.entity.MachineStatus;
import com.whmskj.xjlhsc.stationmachine.pojo.vo.RealTimeMachineInspectionDetailVO;
import com.whmskj.xjlhsc.stationmachine.pojo.vo.RealTimeMachineInspectionVO;
import com.whmskj.xjlhsc.stationmachine.service.IRealTimeMachineInspectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author jiaruchun
 * @date 2025-09-18 11:22
 */
@Service
public class RealTimeMachineInspectionServiceImpl implements IRealTimeMachineInspectionService {
    @Autowired
    private RealTimeMachineInspectionMapper realTimeMachineInspectionMapper;

    @Override
    public RealTimeMachineInspectionVO getRealTimeMachineInspection() {
        RealTimeMachineInspectionVO realTimeMachineInspectionVO = new RealTimeMachineInspectionVO();
        //梳棉
        RealTimeMachineInspectionDetailVO realTimeMachineInspectionDetailVO = realTimeMachineInspectionMapper.getRealTimeMachineInspectionDetailVO("梳棉");
        //并条
        RealTimeMachineInspectionDetailVO realTimeMachineInspectionDetailVO2 = realTimeMachineInspectionMapper.getRealTimeMachineInspectionDetailVOBingTiao();
        //粗纱
        RealTimeMachineInspectionDetailVO realTimeMachineInspectionDetailVO3 = realTimeMachineInspectionMapper.getRealTimeMachineInspectionDetailVO("粗纱");
        //细纱
        RealTimeMachineInspectionDetailVO realTimeMachineInspectionDetailVO4 = realTimeMachineInspectionMapper.getRealTimeMachineInspectionDetailVO("细纱");
        //络筒
        RealTimeMachineInspectionDetailVO realTimeMachineInspectionDetailVO5 = realTimeMachineInspectionMapper.getRealTimeMachineInspectionDetailVO("络筒");
        //全部
        RealTimeMachineInspectionDetailVO realTimeMachineInspectionDetailVO6 = realTimeMachineInspectionMapper.getRealTimeMachineInspectionDetailVOTotal();
        List<RealTimeMachineInspectionDetailVO> realTimeMachineInspectionDetailVOList = new ArrayList<>();
        realTimeMachineInspectionDetailVOList.add(realTimeMachineInspectionDetailVO);
        realTimeMachineInspectionDetailVOList.add(realTimeMachineInspectionDetailVO2);
        realTimeMachineInspectionDetailVOList.add(realTimeMachineInspectionDetailVO3);
        realTimeMachineInspectionDetailVOList.add(realTimeMachineInspectionDetailVO4);
        realTimeMachineInspectionDetailVOList.add(realTimeMachineInspectionDetailVO5);
        realTimeMachineInspectionDetailVOList.add(realTimeMachineInspectionDetailVO6);
        realTimeMachineInspectionVO.setList(realTimeMachineInspectionDetailVOList);
        //状态
        MachineStatus machineStatus = realTimeMachineInspectionMapper.getShuMianOperationalStatus();
        MachineStatus machineStatus1 = realTimeMachineInspectionMapper.getBingTiaoOperationalStatus();
        MachineStatus machineStatus2 = realTimeMachineInspectionMapper.getCuShaOperationalStatus();
        MachineStatus machineStatus3 = realTimeMachineInspectionMapper.getXiShaOperationalStatus();
        MachineStatus machineStatus4 = realTimeMachineInspectionMapper.getLuoTongOperationalStatus();
        realTimeMachineInspectionVO.setTotalNormalRunningNum(machineStatus.getNORMAL() + machineStatus1.getNORMAL() + machineStatus2.getNORMAL() + machineStatus3.getNORMAL() + machineStatus4.getNORMAL());
        realTimeMachineInspectionVO.setTotalTemporaryStopNum(machineStatus.getTEMPORARY_STOP() + machineStatus1.getTEMPORARY_STOP() + machineStatus2.getTEMPORARY_STOP() + machineStatus3.getTEMPORARY_STOP() + machineStatus4.getTEMPORARY_STOP());
        realTimeMachineInspectionVO.setTotalMaintenanceStopNum(machineStatus.getPLAN_STOP() + machineStatus1.getPLAN_STOP() + machineStatus2.getPLAN_STOP() + machineStatus3.getPLAN_STOP() + machineStatus4.getPLAN_STOP());
        realTimeMachineInspectionVO.setTotalMaintenanceNum(machineStatus.getMAINTENANCE() + machineStatus1.getMAINTENANCE() + machineStatus2.getMAINTENANCE() + machineStatus3.getMAINTENANCE() + machineStatus4.getMAINTENANCE());
        realTimeMachineInspectionVO.setTotalOfflineNum(machineStatus.getOFFLINE() + machineStatus1.getOFFLINE() + machineStatus2.getOFFLINE() + machineStatus3.getOFFLINE() + machineStatus4.getOFFLINE());
        return realTimeMachineInspectionVO;
    }
}
